#ifndef MESSAGEQUEUE_H
#define MESSAGEQUEUE_H

#include "Singleton.h"
#include "Mutex.h"
#include "MutexLocker.h"
#include "GameMessage.h"

#include <stack>
#include <queue>

class MessageQueue : public Uncopyable
{
	MessageQueue();
	friend class Singleton<MessageQueue>;
public:
	void AddMessage(GameMessage* gm);
	void Update();
	
	void Clear();
	void AddLagTime(unsigned int lag);
private:
	void MaxLagTime();
private:
	Mutex m_mutex;
	typedef std::priority_queue<PGameMessage> GameMsgQueue;
	GameMsgQueue m_q;
	std::stack<unsigned int> m_lagTimes;
	unsigned int m_maxLagTime;
};

typedef Singleton<MessageQueue> TheMsgQueue;

#endif // MESSAGEQUEUE_H